/*
 *	Player.h
 *	SpaceTrader
 *
 *	Player class manages player's attributes throughout the game.
 *	This includes managing credits, ships, crew, and equipment.
 */
#pragma once
#include "GuiTools.h"
#include "Ship.h"
#include "Merchant.h"
#include "SpaceTrader.h"
#include "boost/archive/text_oarchive.hpp"
#include "boost/archive/text_iarchive.hpp"
#include <fstream>

class Player : public Merchant
{
private:
    friend class boost::serialization::access;
	
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
    {
        //for serialization, save/load these fields
        ar & name;
        ar & credits;
        ar & stats;
        ar & curr_ship;
        ar & inventory;
		ar & itemCount;
		ar & itemLimit;
    }
	int credits;
	Ship *curr_ship;
	std::string name;

	//Corresponding image file for player TODO: create method to switch image if active ship changes
	SDL_Surface *icon;
	
	
	
	int itemLimit;
	int stats[4];
	
	//Player's Inherits Inventory
	
public:
	//Constructor
	Player();
	Player(const Player &P);
	~Player();
    Player& operator=(const Player &P);
	
	void setName(std::string);
	
	std::string getName();
	
	void setStats(int newStats[4]);
	
	int *getStats();
	
	int getCredits();
	
    void setCredits(int c);
    
	int getFuel();
    
    void travel(int distance);

	void setShip(Ship *newShip);
	
	Ship *getShip();
    
	bool buy(int good,int price, int qty);
	
	bool sell(int good,int price, int qty);
	
	//bool sell(trade_good_t good, int qty);

	//bool buy(trade_good_t good, int qty);
	
	void show(SDL_Surface *screen);
	
	int *retInvArray();
    
    //returns 0 if successful, 1 if not enough credits, 2 if not enough capacity
    int buyFuel(int qty, double price);

};
